package cn.jnetty.ioc.definition;

import cn.jnetty.api.annotation.JComponent;
import cn.jnetty.api.exception.JnettyIocException;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/4/3 18:37
 * 描述：
 */
public class JComponentBeanDefinition extends JDefaultBeanDefinition {
    public JComponentBeanDefinition(JComponent component, Class<?> clazz) {
       super(component,clazz);
        init();
    }
    @Override
    protected void init() {
        try {
            Object o = clazz.newInstance();
            JDefaultBeanDefinitionFactory.getInstance().put(((JComponent)annotation).value(),clazz, o);
        } catch (Exception e) {
            throw new JnettyIocException("创建bena异常{0}",e,clazz.getName());
        }
    }
}
